<?php
  	function upLoadFile( $fileName, $fileType = "", $fileSize = "", $fileError = "", $root_path, $destination_path )
    {	$files="";
        if( true )
        {
            if( $fileError > 0 )
            {
                echo "<br>Return Code: " . $fileError . "<br />";
                return false;
            }else{
                if ( file_exists($destination_path.date('YmdHi_').$fileName) ){
                    echo "\"".$fileName . "\" already exists. <br>";
                }else{
                    move_uploaded_file($root_path, $destination_path.date('YmdHi_').$fileName);
					//$files=$destination_path.date('YmdHi_').$fileName;
					$files=date('YmdHi_').$fileName;					
                }
            }
            return $files;
        }else{
            echo "<br><span style=\"color: red\"><b>File Bi Lỗi : \"".$fileName."\"</b></span><br>";
            return false;
        }
    }
	function divPages($total = 0,$currentPage = 0,$div = 5,$rows = 10,$attribute)
	{
			if(!$total || !$rows || !$div || $total<=$rows) return false;
			$nPage = floor($total/$rows) + (($total%$rows)?1:0);
			$nDiv  = floor($nPage/$div) + (($nPage%$div)?1:0);
			$currentDiv = floor($currentPage/$div) ;
			$sPage = '';
			if($currentDiv) {
				$sPage .= ' &nbsp;<a href="'.$attribute.'0" style="text-decoration:none" > First </a>&nbsp; ';
				$sPage .= ' &nbsp;<a href="'.$attribute.($currentDiv*$div - 1).'" style="text-decoration:none">previus</a>&nbsp; ';
			}
			$count =($nPage<=($currentDiv+1)*$div)?($nPage-$currentDiv*$div):$div;
			for($i=0;$i<$count;$i++){
				$page = ($currentDiv*$div + $i);
				if($page==$currentPage){
					$sPage .= ' [ '.($page).' ] ';
				}else{
					$sPage .= ' &nbsp;<strong><a href="'.$attribute.($currentDiv*$div + $i ).'" style="text-decoration:none" >'.($page).'</a></strong>&nbsp; ';
				}
			}
			if($currentDiv < $nDiv - 1){
				$sPage .= ' &nbsp;<a href="'.$attribute.(($currentDiv+1)*$div  ).'" style="text-decoration:none">Next</a>&nbsp; ';
				$sPage .= ' &nbsp;<a href="'.$attribute.(($nDiv-1)*$div + 1 ).'" style="text-decoration:none">Last</a>&nbsp; ';
			}
			return $sPage ;
		}
	
	
	
	
		
?>
 
	